
package com.epam.android.training.day13.task2;

import com.google.android.maps.ItemizedOverlay;
import com.google.android.maps.OverlayItem;

import android.graphics.drawable.Drawable;

/**
 * Overlay used to show geolocation changes on the map. Supports only one item
 * at the particular place.
 * 
 * @author Anton Novikau
 */
public class MapOverlay extends ItemizedOverlay<OverlayItem> {
  private OverlayItem item;

  /**
   * Creates an instance of MapOverlay.
   * 
   * @param defaultMarker overlay icon
   */
  public MapOverlay(Drawable defaultMarker) {
    super(boundCenter(defaultMarker));
  }

  @Override
  protected OverlayItem createItem(int i) {
    return item;
  }

  @Override
  public int size() {
    // overlay supports only one item
    return item != null ? 1 : 0;
  }

  public void setItem(OverlayItem item) {
    this.item = item;
    populate();
  }
}
